import variables from "@/style/variables.module.scss"

export const useSettingsStore = defineStore(
  "settings",
  () => {
    // 选择主题
    const settings = reactive({
      theme: variables.theme,
      originalThem: "",
      tagsView: false,
      sidebarLogo: false
    })

    type ISetting = typeof settings

    const changeSetting = <T extends keyof ISetting>({
      key,
      value
    }: {
      key: T
      value: ISetting[T]
    }) => {
      settings[key] = value
    }

    return { settings, changeSetting }
  },
  {
    persist: {
      storage: window.sessionStorage,
      pick: ["settings.theme", "settings.tagsView", "settings.sidebarLogo"]
    }
  }
)
